#!/usr/local/bin/python3

__author__ = '曹植'

import os

from pyapollo.apollo_client import ApolloClient

# dic = {'DEV': 'http://192.168.1.202:8080', 'FAT': 'http://192.168.1.204:8080', 'PRO': 'http://172.18.55.34:8080'}
# path = os.path.split(os.path.abspath(__file__))[0]
# with open(path + '/server.properties', 'r') as f:
#     env = f.read().split('=')[1].strip().upper()
# apollo_client = ApolloClient(app_id=10014, cluster='default', config_server_url=dic.get(env))

# # redis配置
# REDIS_CONFIG = apollo_client.get_value('redis_config', '')
# REDIS_KEY = apollo_client.get_value('REDIS_KEY', 'proxy')
#
# # 代理分数
# MAX_SCORE = int(apollo_client.get_value('MAX_SCORE', 0))
# MIN_SCORE = int(apollo_client.get_value('MIN_SCORE', 0))
# INITIAL_SCORE = int(apollo_client.get_value('INITIAL_SCORE', 0))
#
# VALID_STATUS_CODES = eval(apollo_client.get_value('VALID_STATUS_CODES', '[]'))
#
# # 代理池数量界限
# POOL_UPPER_THRESHOLD = int(apollo_client.get_value('POOL_UPPER_THRESHOLD', 10))
#
# # 检查周期
# TESTER_CYCLE = int(apollo_client.get_value('TESTER_CYCLE', 60))
# # 获取周期
# GETTER_CYCLE = int(apollo_client.get_value('GETTER_CYCLE', 60))
#
# # 测试API，建议抓哪个网站测哪个
# TEST_URL = apollo_client.get_value('TEST_URL', 'http://www.baidu.com')
#
# # API配置
# API_HOST = apollo_client.get_value('API_HOST', '127.0.0.1')
# API_PORT = apollo_client.get_value('API_PORT', '5000')
#
# # 开关
# TESTER_ENABLED = eval(apollo_client.get_value('TESTER_ENABLED', 'True'))
# GETTER_ENABLED = eval(apollo_client.get_value('GETTER_ENABLED', 'True'))
# API_ENABLED = eval(apollo_client.get_value('API_ENABLED', 'True'))
#
# # 最大批测试量
# BATCH_TEST_SIZE = int(apollo_client.get_value('BATCH_TEST_SIZE', 1))
#
# # 爬虫开关
# XICI_ENABLED = eval(apollo_client.get_value('XICI_ENABLED', 'True'))
# KUAI_ENABLED = eval(apollo_client.get_value('KUAI_ENABLED', 'True'))
# IP3366_ENABLED = eval(apollo_client.get_value('IP3366_ENABLED', 'True'))
# DAILI666_ENABLED = eval(apollo_client.get_value('DAILI666_ENABLED', 'True'))
# DATA5U_ENABLED = eval(apollo_client.get_value('DATA5U_ENABLED', 'True'))
# XIAOER_ENABLED = eval(apollo_client.get_value('XIAOER_ENABLED', 'True'))
# QIYUN_ENABLED = eval(apollo_client.get_value('QIYUN_ENABLED', 'True'))
# DAILI89_ENABLED = eval(apollo_client.get_value('DAILI89_ENABLED', 'True'))
# GOUBANJIA_ENABLED = eval(apollo_client.get_value('GOUBANJIA_ENABLED', 'True'))
# IPHAI_ENABLED = eval(apollo_client.get_value('IPHAI_ENABLED', 'True'))
# XSDAILI_ENABLED = eval(apollo_client.get_value('XSDAILI_ENABLED', 'True'))
# LABPROXY_ENABLED = eval(apollo_client.get_value('LABPROXY_ENABLED', 'True'))
# SHENJI_ENABLED = eval(apollo_client.get_value('SHENJI_ENABLED', 'True'))
# NIMA_ENABLED = eval(apollo_client.get_value('NIMA_ENABLED', 'True'))
# IHUAN_ENABLED = eval(apollo_client.get_value('IHUAN_ENABLED', 'True'))
# redis配置
REDIS_CONFIG = "{'host': '127.0.0.1', 'port': '6379'}"
REDIS_KEY = 'proxy'

# 代理分数
MAX_SCORE = 100
MIN_SCORE = 0
INITIAL_SCORE = 10

VALID_STATUS_CODES = [200, 300, 301]
# 代理池数量界限
POOL_UPPER_THRESHOLD = 10

# 检查周期
TESTER_CYCLE = 60
# 获取周期
GETTER_CYCLE = 60

# 测试API，建议抓哪个网站测哪个
TEST_URL = 'http://www.baidu.com'

# API配置
API_HOST = '0.0.0.0'
API_PORT = '5000'

# 开关
TESTER_ENABLED = True
GETTER_ENABLED = True
API_ENABLED = True

# 最大批测试量
BATCH_TEST_SIZE = 10

# 爬虫开关
XICI_ENABLED = True
KUAI_ENABLED = True
IP3366_ENABLED = True
DAILI666_ENABLED = True
DATA5U_ENABLED = True
XIAOER_ENABLED = True
QIYUN_ENABLED = True
DAILI89_ENABLED = True
GOUBANJIA_ENABLED = True
IPHAI_ENABLED = True
XSDAILI_ENABLED = True
LABPROXY_ENABLED = True
SHENJI_ENABLED = True
NIMA_ENABLED = True
IHUAN_ENABLED = True
